package com.google.code.chaotic.client.ui;

import static com.google.code.chaotic.client.Constants.LIGHT_BLUE;

import com.google.code.chaotic.client.ui.ProfileDetailsPanel.State;
import com.google.gwt.core.client.GWT;
import com.google.gwt.dom.client.Style;
import com.google.gwt.dom.client.Style.Cursor;
import com.google.gwt.dom.client.Style.Unit;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.ui.DockLayoutPanel;
import com.google.gwt.user.client.ui.FlowPanel;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.Image;
import com.google.gwt.user.client.ui.SimplePanel;

//

public class RegistrationPanel extends DockLayoutPanel {

	private FlowPanel logosPanel = new FlowPanel();
	private Image logo = new Image("/images/chaos-logo.png");
	private Image logoDesc = new Image("/images/chaos-desc.png");

	//

	private ProfileDetailsPanel profileDetailsPanel = new ProfileDetailsPanel();

	//

	public RegistrationPanel() {
		super(Unit.EM);
		profileDetailsPanel.setState(State.NEW);
	}

	@Override
	protected void onLoad() {
		super.onLoad();

		logosPanel.add(logo);
		logosPanel.add(logoDesc);

		this.addNorth(logosPanel, 6);

		HTML footerHtml = ChaosPanel.getFooterHtml();
		SimplePanel footerPanel = new SimplePanel();
		footerPanel.setWidget(footerHtml);
		this.addSouth(footerPanel, 4);

		// dockPanel.add(decoratorPanel, DockLayoutPanel.CENTER);
		this.add(profileDetailsPanel);

		logosPanel.getElement().getStyle().setBackgroundColor(LIGHT_BLUE);

		Style logoStyle = logo.getElement().getStyle();
		Style logoDescStyle = logoDesc.getElement().getStyle();

		logoStyle.setMargin(1, Unit.EM);
		logoDescStyle.setMargin(1, Unit.EM);
		logoDescStyle.setPaddingLeft(0, Unit.EM);

		footerPanel.getElement().getStyle().setMarginTop(1, Unit.EM);

		logo.getElement().getStyle().setCursor(Cursor.POINTER);
		logo.addClickHandler(new ClickHandler() {
			@Override
			public void onClick(ClickEvent event) {
				Window.open(GWT.getHostPageBaseURL(), "_self", "");
			}
		});
	}
}
